import VueI18n from "vue-i18n";
import Vue from "vue";
// langs locales
import enLocale from "./lang/en";
import zhCNLocale from "./lang/zh-CN";

Vue.use(VueI18n);

const locale = localStorage.getItem("lang") || "zh-CN",
  messages = {
    en: enLocale,
    "zh-CN": zhCNLocale,
  },
  i18n = new VueI18n({
    /* 默认的语言 */
    locale,
    /** 默认回退的语言 */
    fallbackLocale: "zh-CN",
    /** slience warning */
    silentFallbackWarn: true,
    /* 语言配置项 */
    messages,
  });

/* test */
// console.log(i18n.t("COMMON.HELLO"));

export default i18n;
